
import numpy as np 

#radix 4 twiddle dif
for stage in range(5):
    k_len = int(4**(5-stage) / 4)
    N = int(4**(5-stage))

    k = np.reshape(np.linspace(0,k_len-1, k_len), [1, k_len])
    W2kr = np.cos(2*np.pi * 2*k/N)
    W2ki = -np.sin(2*np.pi * 2*k/N)
    W1kr = np.cos(2*np.pi * k/N)
    W1ki = -np.sin(2*np.pi * k/N)
    W3kr = np.cos(2*np.pi * 3*k/N)
    W3ki = -np.sin(2*np.pi * 3*k/N)

    WR = np.concatenate([W2kr, W1kr, W3kr], axis=1)
    WI = np.concatenate([W2ki, W1ki, W3ki], axis=1)
    W = np.concatenate([WR, WI], axis=0)
    np.savetxt('r4difw{}.txt'.format(stage+1), W)
    pass


# radix 2 twiddle
for stage in range(10):
    twiddle_len = int(2**(stage))
    N = int(2**(stage+1))
    k = np.reshape(np.linspace(0,twiddle_len-1, twiddle_len), [1, twiddle_len])
    w_r = np.cos(2*np.pi * k/N)
    w_i = np.sin(2*np.pi * k/N)
    w = np.float32(np.concatenate([w_r, w_i]))
    np.savetxt('w{}.txt'.format(stage+1), w)
    pass




